package com.jsmile.cloud.msgcenter.web.mq;

import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.jsmile.cloud.msgcenter.api.constants.MsgConstants;
import com.jsmile.cloud.msgcenter.api.req.ReqNotifyCreate;
import com.jsmile.cloud.msgcenter.msg.repo.MsNotifyRepository;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 统一通知接收
 *
 * @author 亮亮
 * @version 1.0.0
 * @date 2017年3月30日 下午3:34:16
 */
@Component
@Slf4j
@AllArgsConstructor
public class NotifyListener {

    private final MsNotifyRepository msNotifyRepository;

    @RabbitListener(queuesToDeclare = @Queue(MsgConstants.SmsMq.NOTIFY_QUEUE))
    public void receiveSms(ReqNotifyCreate reqNotifyCreate) {
        log.info("统一通知发送参数：{}", JSON.toJSONString(reqNotifyCreate));
        msNotifyRepository.create(reqNotifyCreate);
    }
}
